package com.javasm.springmybatis.common.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
//从spring容器中获取对象
public class SpringContainerUtils implements ApplicationContextAware {

    private static  ApplicationContext applicationContext1 ;


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        applicationContext1 =applicationContext;
    }

    public static <T> T getBean(Class<T> clazz){
        return applicationContext1.getBean(clazz);
    }


}